﻿using StudySystem.MainLogic;
using StudySystem.MainLogic.FormControl;
using StudySystem.MainLogic.Items;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace StudySystem.Windows
{
    public partial class FormSearch : Form
    {
        public FormSearch()
        {
            InitializeComponent();
        }

        private void FormSearch_Load(object sender, EventArgs e)
        {
            FormController.ConfigCombobox(this.cbbSubject, UserManagement.subjects.ToArray<ClassSubject>(), "SubjectName");
     
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            List<ClassQuestion> questions = null;
            if (cbbSubject.SelectedIndex == 0)
            {
                questions = ClassQuestion.SearchAllSubjectQues(txtSearchContent.Text);
            }
            else
            {
                questions = ClassQuestion.SearchOneSubjectQues(
                    (cbbSubject.SelectedItem as ClassSubject), 
                    txtSearchContent.Text
                    );
            }
            FormQuesControl.RenewQuestion(flpQuestions, questions);
        }
    }
}
